<%@ page import="java.net.URLDecoder" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%
    Cookie[] cookies = request.getCookies();
    String username="";
%>

<html>
<head>
    <title>书籍列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入 Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"rel="stylesheet">
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/bootstrap.min.js"></script>
    <style>
        body{
            width: 100%;
        }


        .sb{
            position: absolute;
            left: 50%;
            transform: translate(-50%,-50%);
        }
        img{
            width: 190px;
            height: 240px;
        }

        td{
            line-height: 240px;
        }

        .dropdown-toggle{
            border: none;
            font-size: 16px;
            font-weight: bold;
            margin-bottom: -6px;
            margin-left: -14px;
            background-color: #28FF28;
        }
        #sbbbb{
            position: sticky;
            top: 0;
            background-color: #28FF28;
        }

    </style>

</head>
<body>
​
<div class="container">
    ​
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>
                    <small>用户列表 —— 显示所有用户</small>
                </h1>
                <form action="${pageContext.request.contextPath}/user/queryUserByUserName" method="get">
                    <input type="text" name="userName" id="name" placeholder="请输入要查询的用户" value="${key}"/>
                    <input type="submit" id="btn04">
                </form>
            </div>
        </div>
    </div>
    ​
    <div class="row">
        <div class="col-md-4 column">
            <a class="btn btn-primary"href="${pageContext.request.contextPath}/user/toaddUser">新增</a>
        </div>
    </div>
    ​
    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-hover table-striped">
                <thead id="sbbbb">
                <tr>
                    <th>用户头像</th>
                    <th>用户名</th>
                    <th>用户密码</th>
                    <th>用户昵称</th>
                    <th class="dsb">
                        <div class="dropdown">
                            <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                用户类型
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                                <li><a href="${pageContext.request.contextPath}/user/allUser">全部</a></li>
                                <c:forEach items="${type}" var="type">
                                    <li><a href="${pageContext.request.contextPath}/user/queryUserByType?type=${type}">${type}</a></li>
                                </c:forEach>
                            </ul>
                        </div>
                    </th>
                    <th>用户创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                ​
                <tbody>
                    <tr>
                        <td><img src="${user.avatar}" alt="${user.userName}"></td>
                        <td>${user.userName}</td>
                        <td>${user.password}</td>
                        <td>${user.nickname}</td>
                        <td><c:choose><c:when test="${user.type==1}">普通用户</c:when><c:otherwise>管理员</c:otherwise></c:choose></td>
                        <td>${user.createTime}</td>
                        <td>
                            <a href="${pageContext.request.contextPath}/user/toupdateUser?id=${user.id}">更改</a> |
                            <a href="${pageContext.request.contextPath}/user/deleteUser?id=${user.id}">删除</a>
                        </td>
                    </tr>
                </tbody>

            </table>
        </div>
    </div>
</div>
<p id="ssr"></p>

</div>

</div>
</body>
</html>